import librosa  # 填充，默认频率为22050，可以改变频率

import numpy as np
import librosa.display
import matplotlib.pyplot as plt


data1, sample_rate = librosa.load('./resources/yqx.wav')
print("长度 = {0} 秒".format(len(data1) / sample_rate))
melspec = librosa.feature.melspectrogram(data1, sample_rate, n_fft=1024, hop_length=512, n_mels=128)
logmelspec = librosa.power_to_db(melspec)
librosa.display.specshow(logmelspec, sr=sample_rate, x_axis='time', y_axis='mel')

#plt.figure(figsize=(14, 5))
#librosa.display.waveplot(data1, sample_rate)
plt.show()
